package org.asiainfo.system.dubbo;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.asiainfo.common.core.utils.MapstructUtils;
import org.asiainfo.system.api.RemoteDeptService;
import org.asiainfo.system.api.domain.vo.RemoteDeptVo;
import org.asiainfo.system.domain.vo.SysDeptVo;
import org.asiainfo.system.service.SysDeptService;
import org.springframework.stereotype.Service;

/**
 * 部门服务
 *
 * @author dotor-ww
 */
@Service
@DubboService
@RequiredArgsConstructor
@Slf4j
public class RemoteDeptServiceImpl implements RemoteDeptService {

    private final SysDeptService sysDeptService;

    /**
     * 根据部门id，查询部门信息
     *
     * @param deptId 部门id
     * @return 部门信息
     */
    @Override
    public RemoteDeptVo selectDeptById(Long deptId) {
        SysDeptVo sysDeptVo = sysDeptService.queryById(deptId);
        return MapstructUtils.convert(sysDeptVo, RemoteDeptVo.class);
    }

    /**
     * 通过部门ID查询部门名称
     *
     * @param deptIds 部门ID串逗号分隔
     * @return 部门名称串逗号分隔
     */
    @Override
    public String selectDeptNameByIds(String deptIds) {
        return sysDeptService.selectDeptNameByIds(deptIds);
    }
}
